package com.iran.observer.jingzongObserverTest;

import java.util.ArrayList;
import java.util.List;

public class LiangGeSubject implements ISubject {
    private String action;
    private List<IObserver> liangGeObeservers = new ArrayList<>();

    @Override
    public void addObserver(IObserver observer) {
        if (observer == null) {
            return;
        }
        if (!liangGeObeservers.contains(observer)) {
            liangGeObeservers.add(observer);
        }
    }

    @Override
    public void delObserver(IObserver observer) {
        liangGeObeservers.remove(observer);
    }

    @Override
    public void notifyObservers() {
        liangGeObeservers.forEach(i->i.update());
    }

    public String getAction() {
        return action;
    }

    public void setAction(String action) {
        this.action = action;
    }
}
